package com.vstartek.dm.util;

import java.io.Serializable;
import java.util.List;

import javax.xml.bind.annotation.XmlType;
@XmlType(name = "Page", namespace = "util.dm.vstartek.com")
public class Page<T> implements Serializable{

	private static final long serialVersionUID = 1L;
	private int totalPage;
	private int currentPage;
	private int totalRecords;
	private List<T> list;
	private int pageSize;
	public Page(List<T> list,Long totalnum,PageParam pageParam){
		this.list = list;
		this.totalRecords = totalnum.intValue();
		this.pageSize = pageParam.getRows();
		this.currentPage  = pageParam.getPage();
		
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalPage() {
		if(pageSize!=0){
			if(totalRecords%pageSize==0){
				totalPage=totalRecords/pageSize;
			}else{
				totalPage=totalRecords/pageSize+1;
			}
		}
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getTotalRecords() {
		return totalRecords;
	}
	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}

}
